﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.CApExportToRTRMaterial
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;


namespace DnProcessSimulateCommands.ExportToRTR{

public class CApExportToRTRMaterial : ICApExportToRTRWriteable
{
  private string m_name;
  private double[] m_rgba;
  private string m_textureFile;

  public CApExportToRTRMaterial(string name, double[] rgba = null, string texture = null)
  {
    this.m_name = name;
    this.m_rgba = rgba;
    this.m_textureFile = texture;
  }

  public void Write(CApExportToRTRXmlWriter writer)
  {
    writer.WriteStartElement("material");
    writer.WriteAttributeString("name", this.m_name);
    this.WriteColor(writer);
    this.WriteTexture(writer);
    writer.WriteEndElement();
  }

  private void WriteColor(CApExportToRTRXmlWriter writer)
  {
    if (this.m_rgba == null)
      return;
    writer.WriteStartElement("color");
    writer.WriteAttributeString("rgba", ((IEnumerable<double>) this.m_rgba).DoubleArrayToString());
    writer.WriteEndElement();
  }

  private void WriteTexture(CApExportToRTRXmlWriter writer)
  {
    if (this.m_textureFile == null)
      return;
    writer.WriteStartElement("texture");
    writer.WriteAttributeString("filename", this.m_textureFile);
    writer.WriteEndElement();
  }
}
